package com.wtwd.campus.fjryE15.entity.vo;

import com.alibaba.fastjson.JSONArray;
import com.wtwd.campus.fjryE15.entity.PhoneData;
import com.wtwd.campus.fjryE15.enumeration.PhoneEnum;
import com.wtwd.campus.fjryE15.untils.XyyUtiils;
import com.wtwd.campus.utils.DateUtils;
import com.wtwd.campus.wx.utils.AESUtils;

import java.util.Date;
import java.util.List;

/**
 * @author mjy
 * @date 2022/09/21
 * @description
 */
public class ListVo {

    private String appId;

    private String time;

    private String randomStr;

    private String sign;

    private String sosNum;

    private String familyNum;

    private String whiteNum;

    private String sosList;

    private String familyList;

    private String whiteList;

    public String getAppId() {
        return appId;
    }

    public void setAppId(String appId) {
        this.appId = appId;
    }

    public String getTime() {
        return time;
    }

    public void setTime(String time) {
        this.time = time;
    }

    public String getRandomStr() {
        return randomStr;
    }

    public void setRandomStr(String randomStr) {
        this.randomStr = randomStr;
    }

    public String getSign() {
        return sign;
    }

    public void setSign(String sign) {
        this.sign = sign;
    }

    public String getSosNum() {
        return sosNum;
    }

    public void setSosNum(String sosNum) {
        this.sosNum = sosNum;
    }

    public String getFamilyNum() {
        return familyNum;
    }

    public void setFamilyNum(String familyNum) {
        this.familyNum = familyNum;
    }

    public String getWhiteNum() {
        return whiteNum;
    }

    public void setWhiteNum(String whiteNum) {
        this.whiteNum = whiteNum;
    }

    public String getSosList() {
        return sosList;
    }

    public void setSosList(String sosList) {
        this.sosList = sosList;
    }

    public String getFamilyList() {
        return familyList;
    }

    public void setFamilyList(String familyList) {
        this.familyList = familyList;
    }

    public String getWhiteList() {
        return whiteList;
    }

    public void setWhiteList(String whiteList) {
        this.whiteList = whiteList;
    }

    public static ListVo createListVo(List<PhoneData> sosPhones,List<PhoneData> familyPhones,List<PhoneData> whitePhones) {
        ListVo listVo = new ListVo();
        listVo.setAppId(XyyUtiils.APP_ID);
        listVo.setTime(DateUtils.format(new Date(), DateUtils.dateFormat15));
        listVo.setRandomStr(XyyUtiils.generateStr(8));
        listVo.setSign(XyyUtiils.getRySign(listVo.getAppId(), listVo.getTime(), listVo.getRandomStr(), XyyUtiils.APP_KEY));
        listVo.setSosNum(String.valueOf(PhoneEnum.SOS_PHONE.getMaxLength()));
        listVo.setFamilyNum(String.valueOf(PhoneEnum.FAMILY_PHONE.getMaxLength()));
        listVo.setWhiteNum(String.valueOf(PhoneEnum.WHITE_PHONE.getMaxLength()));
        listVo.setSosList(AESUtils.enCode(JSONArray.toJSONString(sosPhones),XyyUtiils.APP_KEY));
        listVo.setFamilyList(AESUtils.enCode(JSONArray.toJSONString(familyPhones),XyyUtiils.APP_KEY));
        listVo.setWhiteList(AESUtils.enCode(JSONArray.toJSONString(whitePhones),XyyUtiils.APP_KEY));
        return listVo;
    }

    private ListVo() {
    }

}
